import React from 'react';
import { connect } from 'dva'
import { routerRedux } from 'dva/router';
import { Icon, List, WhiteSpace, SearchBar, WingBlank} from 'antd-mobile';
import banner1 from '../../../../assets/work/banner2.jpg';
import banner2 from '../../../../assets/work/banner4.jpg';
import banner3 from '../../../../assets/work/banner5.jpg';
import banner4 from '../../../../assets/work/banner6.jpg';

const Item = List.Item;
const Brief = Item.Brief;
class partybuilding extends React.Component{
  constructor(props) {
    super(props);
    this.state = {}
    if (this.props.location.query.code) {
      this.props.dispatch({
        type: 'partybuildings/fetch1',
        payload: {org_code:"500"},//org_code:this.props.location.query.code
      });
    }
  }
  //党员详情列表跳转
 onClicks = (code) =>{
    const data={code:code};
    this.props.dispatch(
      routerRedux.push({
        pathname:"/work/zzadminister/dangyuanlist",
        query:data,
      })
    )
  };


  render(){
    const orgList = [];
    const orgData = this.props.list;
    for (let key in orgData) {
      orgList.push(orgData[key])
    }
    return(
      <div>
        <div>

          <WhiteSpace/>
          <div style={{height:'2rem',backgroundColor:'#fff'}}>
            <WingBlank> <SearchBar placeholder="搜索" maxLength={8} /></WingBlank>
        <div style={{marginTop:'0.5rem',color:'#5B91E6',marginLeft:'0.3rem'}}>机场集团&nbsp;>&nbsp;<span style={{color:'#B6B6B6',fontSize:'0.8em'}}>{this.props.location.query.name?this.props.location.query.name:""}</span></div>
          </div>
          <WhiteSpace/>
          <div>
            {this.props.list &&
            <List>
              {
                orgList.map((it) => {
                  return <Item thumb={it.photo ? it.photo : banner4} onClick={()=>this.onClicks(it.code)}>
                    {it.name}({it.sex})
                    <Brief>{it.job}</Brief>
                  </Item>
                })
              }
            </List>
            }
          </div>
        </div>
      </div>
    );
  }
}

function mapStateToProps({ partybuildings, dangyuanlists }) {
  return {
    list: partybuildings.menbers,
  };
}
export default connect(mapStateToProps)(partybuilding);
